import cv2 as cv

src = cv.imread("assets/lena.jpg")
tpl = cv.imread("assets/eye.png")
cv.imshow("template image", tpl)
result = cv.matchTemplate(src, tpl, cv.TM_SQDIFF_NORMED)
min_val,max_val,min_loc,max_loc = cv.minMaxLoc(result)
tl = min_loc  #左上角点
th,tw = tpl.shape[:2]  #获取模板图像的高宽
br = (tl[0]+tw,tl[1]+th)  #右下点
cv.rectangle(src,tl,br,(0,0,255),2) #画矩形
cv.imshow("match",src)
cv.waitKey(0)
cv.destroyAllWindows()